
clear
clear all
clear mata
clear matrix
set more off
set matsize 11000
set maxvar 30000
cap log off
capture log close
set emptycells drop
pause on


***********************************************
* USER DEFINE FILEPATH FOR REPLICATION FOLDER *
***********************************************

global path "C:\Users\wb520443\Dropbox\Research Projects\Global pollution\2_analysis\Replication"



***********************************************


global opts		a f plain coll(none) nodep nomti c(b(star fmt(%9.3f)) se(abs par fmt(%9.3f))  ) star(* .10 ** .05 *** .01) noobs nocons

global opts_fs		a f plain coll(none) nodep nomti c(b(star fmt(%9.3f)) se(abs par fmt(%9.3f))) star(* .10 ** .05 *** .01) noobs nocons


global input "$path\data"
global figdat "$path\figdat"
global figures "$path\figures"
global tables "$path\tables"



		
	use "$input/rwi_pollution_analysis_collapsed.dta", replace
	
	label var rwi "Relative wealth"
		cap encode country, g(country_code)
	
		
	
		sort urca
		g count=1
		egen total=total(count)
		g sum=sum(count)
		g share=(sum/total)*100
		
		preserve
			duplicates drop urca, force
		
			twoway(line share urca, lc(cranberry) ///
					xti("Share of pixels in each URCA category") ytitle("Share of RWI points") legend(off) ylabel(,nogrid) xlabel(1 "Most urban" 8 "Peri-urban" 15 "Rural" 30 "Hinterland", nogrid angle(45)))
					
					graph export "$figures/urca_cdf_figure.png", as(png) replace
	
		restore